<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <div>
        <div>数量 <input id="goodsnum" /> </div>
        <div>价格 <input id="goodsprice" /> </div>
        <div>小计<span id="total"></span></div>
    </div>
</body>
<script>
    let goodsnumInput = document.getElementById("goodsnum");
    let goodspriceInput = document.getElementById("goodsprice");
    let totalSpan = document.getElementById("total");

    let  info  = new Proxy({},{
        set(target,attr,value){
            console.log(target,attr,value);
            console.log("对象的赋值操作");
            target[attr] = value;
            complied();
        },
        get(target,attr){
            console.log(target,attr);
            console.log("对象有取值操作");
            return  target[attr];
        }
    })


    function complied(){
        totalSpan.innerHTML  = info.num * info.price;
    }

    goodsnumInput.oninput = function(){
        info.num  = this.value*1;
    }

    goodspriceInput.oninput  = function(){
        info.price = this.value*1;
    }





 
</script>

</html>